package edu.sctu.renpingan.day20150628alltest;



import java.io.*;

/**
 * Created by Administrator on 2015/6/28.
 */
public class Ioutil {
    String json;
    public Ioutil(String json){
        this.json = json;
    }
    public void saveInfo(String savePath) throws IOException {
        File file=new File(savePath);
        if (!file.exists()) {
            file.createNewFile();
        }
        BufferedWriter fw = new BufferedWriter(new FileWriter(savePath , true));
        fw.write(json);
        fw.flush();

    }


    public Appbean saveentity(Appbean appbean,String objectPath ) throws IOException, ClassNotFoundException {

        File file=new File(objectPath);
        if (!file.exists()) {
            file.createNewFile();
        }
        ObjectOutputStream object = new ObjectOutputStream(new FileOutputStream(objectPath));
        object.writeObject(appbean);
        object.close();

        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(objectPath));

        Appbean appbean1 = (Appbean)objectInputStream.readObject();

        objectInputStream.close();
        return appbean1;
    }
}
